<h1>tags</h1>

<ul>
<li> <a href="#1">Synopsis</a>
<ul>
<li> <a href="#2">Working memory</a>
</ul>
<li> <a href="#3">Code</a>
<ul>
<li> <a href="#4">Uses </a>
<li> <a href="#5">Main</a>
</ul>
<li> <a href="#6">Author</a>
</ul>
<p>
Reads a <em>tags file</em>, once, describing a set of web pages. Adds those tags to the top of the tagged pages.
</p>
<a name="1"></a><h2>Synopsis</h2>
<p>
Load a tags file and build the working memory.
</p>
<pre>
    loadTags(tagCommand,file,title,tags,sgat)
</pre>
<p>
Runs <em>tagCommand</em> (e.g. "cat file") to generate the source of the tags
files.  Using that information, it print the tags for a web page. Uses
the working memory buit above.
</p>
<pre>
    print tag(page,file,title,tags,sgat)
</pre>
<a name="2"></a><h3>Working memory</h3>
<p>
file<a href="stem">stem</a> : return the full <em>path</em> of the file whose's stem is <em>stem</em>.
</p>
<pre>
title\[path\] : returns the title of file at _path_.


tags[path,n\] :holds the _n_-th tag of a file at _path_.
</pre>
<p>
sgat[tags,n] : reverse of <em>tags</em>. holds the <em>n</em>-th file of  a <em>tag</em>.
</p>
<a name="3"></a><h2>Code</h2>

<a name="4"></a><h3>Uses </h3>
<p>
<a href="?basename">basename</a> <a href="?phrases">phrases</a> <a href="?o">o</a> <a href="?trim">trim</a> <a href="?stack">stack</a> <a href="?slurp">slurp</a> 
</p>
<a name="5"></a><h3>Main</h3>
<pre>
 function loadTags(ins,files,titles,tags,sgat,     maxLines,i,lines,items,n) {
     maxLines = slurp(ins,lines)
     for(i=1;i&lt;=maxLines;i++) {  
         n = phrases(trim(lines[i]),";",items)
         if (n) 
             tagLine(items,n,files,titles,tags,sgat); 
     }
 } 
 function tagLine(items,n,files,titles,tags,sgat,  dirname,f,i,name) {
      dirname = items[1]
      name    = items[n]
      titles[dirname] = name
      f    = basename(dirname)
      files[gensub(/\..*/,"","g",f)] = dirname; 
      for(i=2;i&lt;n;i++) {
          push2(tags,dirname,items[i]); # files to cats
          push2(sgat,items[i],dirname); # cats to files
      }
  } 
</pre>
<a name="6"></a><h2>Author</h2>
<p>
Tim Menzies
